/**
 * 新增采购退货单页面
 */
function toAddReturnedPO() {
	window.parent.f_addTab('新增采购退货单', '新增采购退货单',
			'../../../manager/purchase/returned/toAddReturnedPO.do?pTabid='
					+ WIN_TAB.getSelectedTabItemID());
}

/**
 * 修改采购退货单页面
 */
function toModifyReturnedPO(rowindex) {
	var repoid = grid.getData()[rowindex].id;
	window.parent.f_addTab('修改采购退货单', '修改采购退货单',
			'../../../manager/purchase/returned/toModifyReturnedPO.do?id='
					+ repoid + '&pTabid=' + WIN_TAB.getSelectedTabItemID());
}

/**
 * 修改采购退货单对应商品信息页面
 */
function toModifyProductOfReturnedPO(rowindex) {
	var porpoid = grid.getData()[rowindex].id;
	var w = $.ligerDialog.open({
		title : '修改采购退货单货品',
		url : '../../../manager/purchase/returned/toModifyProductOfReturnedPO.do?id='
				+ porpoid + '&pTabid=' + WIN_TAB.getSelectedTabItemID(),
		height : 560,
		width : 600,
		isResize : false,
		isDrag : false
	});
	w.show();
}

/**
 * 删除采购退货单里面对应的货品
 * 
 * @param rowindex
 */
function deleteProductOfReturnedPO(rowindex) {
	$.ligerDialog.confirm('确定删除', function(yes) {
				if (yes) {
					var porpoid = grid.getData()[rowindex].id;
					$.post("deleteProductOfReturnedPO.do?id=" + porpoid,
							function(data) {
								if (data == "success") {
									window.parent.$.ligerDialog.warn("作废成功");
									window.location.reload();
								} else {
									window.parent.$.ligerDialog.warn("作废失败");
									window.location.reload();
								}
							});
				}
			});
}

/**
 * 采购退货单作废
 * 
 * @param rowindex
 */
function invalidReturnedPO(rowindex) {
	$.ligerDialog.confirm('确定作废', function(yes) {
				if (yes) {
					var repoid = grid.getData()[rowindex].id;
					$.post("invalidReturnedPO.do?id=" + repoid, function(data) {
								if (data == "success") {
									window.parent.$.ligerDialog.warn("作废成功");
									window.location.reload();
								} else {
									window.parent.$.ligerDialog.warn("作废失败");
									window.location.reload();
								}
							});
				}
			});
}

/**
 * 采购退货单详情
 * 
 * @param rowindex
 */
function showReturnedPODetail(rowindex) {
	var repoid = grid.getData()[rowindex].id;
	window.parent.f_addTab('采购退货单详情', '采购退货单详情',
			'../../../manager/purchase/returned/showReturnedPODetail.do?id='
					+ repoid + '&showList=product&pTabid='
					+ WIN_TAB.getSelectedTabItemID());
}

/**
 * 采购退货单审核
 * 
 * @param rowindex
 */
function toReturnedpoAudit(rowindex) {
	var repoid = grid.getData()[rowindex].id;
	var currentAuditPoint = grid.getData()[rowindex].currentAuditPoint;
	var currentAuditRole = grid.getData()[rowindex].currentAuditRole;
	var w = $.ligerDialog.open({
				title : "采购退货单审核",
				url : 'toReturnedpoAudit.do?id=' + repoid
						+ '&currentAuditPoint=' + currentAuditPoint
						+ '&currentAuditRole=' + currentAuditRole,
				height : 400,
				width : 600,
				isResize : false,
				isDrag : false
			});
	w.show();
}

/**
 * 退货预约页面
 * @param rowindex
 */
function toDispatchingReturnedPO(rowindex) {
	var repoid = grid.getData()[rowindex].id;
	var validityDate = grid.getData()[rowindex].validityDate;
	$.post("validityDateReturnedPO.do",{'validityDate':validityDate,'id':repoid},
			function(data) {
				if(data == 'success'){
					var w = $.ligerDialog.open({
						title : '退货预约',
						url : '../../../manager/purchase/returned/toDispatchingReturnedPO.do?id='
								+ repoid+'&validityDate='+ validityDate + '&pTabid=' + WIN_TAB.getSelectedTabItemID(),
						height : 560,
						width : 600,
						isResize : false,
						isDrag : false
					});
					w.show();
				}else{
					$.ligerDialog.warn("退货单已过期");
				}
			}
	);
	
	
}